<template>
  <!--模态窗 单行-->
  <transition
    name="custom-classes-transition"
    enter-active-class="animated fadeInDown"
    leave-active-class="animated fadeOutUp"
  >

    <div class="modal-ctrl-body" v-show="upUserModalObj.isShow">
      <div class="modal-ctrl-main odd-row-ctrl">
        <div class="modal-title">
          <p>导入用户警员</p>
        </div>
        <div class="modal-ctrl-content">
          <div class="modal-row">
            <div class="modal-form-key f-l">
              导入：
            </div>
            <input type="file" ref="formFile" @change="fileUser" class="modal-text f-l">
          </div>0
        </div>
        <div class="btns text-r">
          <button type="button" class="btn btn-default" @click="close">取消</button>
          <button type="button" class="btn btn-info" @click="subBtn">确定</button>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
    export default {
        name: "UpUserModal",
        props:["upUserModalObj"],
        data(){
          return{
            userModalFile:"",
          }
        },
        methods:{
          fileUser(ele){
            this.userModalFile = ele.target.files[0];
          },
          subBtn(){
            // let configFile = {
            //   headers:{'Content-Type':'multipart/form-data'}
            // };
            let param = new FormData();
            param.append('file',this.userModalFile);
            //POST /bs/batch/policeInfo
            this.$axios.post(this.HOST+"/bs/batch/policeInfoAndUser",param)
              .then((data)=>{
                if( data.data.success === true ){
                  this.s_alert("上传成功！");
                  // alert("上传成功！");
                  this.close();
                }else{
                  this.s_alert(data.data.errorMsg );
                  // alert(data.data.errorMsg );
                }
                //console.log(data);
              })
              .catch((err)=>{
                this.s_alert("上传失败！");
                // alert("上传失败！");
                //console.log(err);
              });
          },
          close(){
            this.$emit("upModalClose");
            this.$refs.formFile.value = "";
          }
        }
    }
</script>

<style scoped>

</style>
